package 力扣日常刷题.木22一月.第16天0128;

/**
 * @author 帅小伙
 * @date 2022/1/28
 * @description
 */
public class Demo20字符串简单找到数组中第一个回文字符串 {


    public String firstPalindrome(String[] words) {
        for (String word : words) {
            if(check(word))return word;
        }
        return "";
    }

    public boolean check(String word) {
        int n = word.length();
        if(n==1)return true;
        for (int i = 0; i < n/2; i++) {
            if(word.charAt(i) != word.charAt(n-1-i))return false;
        }
        return true;
    }

}
